package com.baosight.ice.observer;

import com.alibaba.fastjson.JSONObject;
import com.zeroc.Ice.Current;
import com.zeroc.IceGrid.AdapterDynamicInfo;
import com.zeroc.IceGrid.NodeDynamicInfo;
import com.zeroc.IceGrid.NodeObserver;
import com.zeroc.IceGrid.ServerDynamicInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

public class NodeObserverI implements NodeObserver {
    public static Logger logger= LoggerFactory.getLogger(NodeObserverI.class);
    @Override
    public void nodeInit(NodeDynamicInfo[] nodeDynamicInfos, Current current) {
        System.out.println("nodeInit "+ Arrays.stream(nodeDynamicInfos).map(JSONObject::toJSONString));
    }

    @Override
    public void nodeUp(NodeDynamicInfo nodeDynamicInfo, Current current) {
        System.out.println("nodeUp "+ nodeDynamicInfo);
    }

    @Override
    public void nodeDown(String s, Current current) {
        System.out.println("nodeDown "+ s);
    }

    @Override
    public void updateServer(String s, ServerDynamicInfo serverDynamicInfo, Current current) {
        System.out.println("updateServer "+ s+" "+serverDynamicInfo);
    }

    @Override
    public void updateAdapter(String s, AdapterDynamicInfo adapterDynamicInfo, Current current) {
        System.out.println("updateAdapter "+ s+" "+adapterDynamicInfo);
    }
}
